<?php  
require 'VideoModel.php';
require 'controller.php';
class VideoController extends Controller{

	function __construct(){
      parent::__construct();
    
      $this->mod=new VideoModel();
      
    }
    public function listvideos(){
      //$data=array(array("美国队长","剧情","美国","2016"),array("神盾局特工","科幻","美国","2013"));
      $videomod= new VideoModel();
      $videodata=$videomod->getVideoList();

      $this->assign("videos",$videodata);
      $this->display();
  }
  public function videoform(){
    //var_dump($this);
        $this->display();
       }
    public function addvideo(){
      $result=$this->mod->addVideoInfo();
         if($result==true)
         {
          echo '添加成功！<br>';
          echo '<a href="index.php?c=video&m=listvideos"> 如果没有跳转，请点击这里跳转</a>';

         }
         else
         {
          echo " 添加失败！";
          //header("location:index.php?c=video&m=listvideos");
         }
    }
    public function editvideos(){
    // $vid = $_GET['vid'];
     // $mod = new UserModel();
    $result = $this->mod->getVideobyID($vid);
    $this->assign('video',$result);
    $this->display(); 
  }
 


  public  function updateVideo(){
    // $data = $_POST;
    // $model = new UserModel();
    $result = $this->mod->updateVideoInfo($data);
    if($result){
      echo '更新成功 <a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
        header("refresh:3;url='index.php?c=video&m=listvideos'");
    }
    else{
      echo "更新失败！<br/>";
        echo "<a href='index.php?c=video&m=editvideosr&vid=".$data['vid']."'>返回</a>";
    }
  }
  public function delVideo(){
    $vid = $_GET['vid'];
    // $model = new UserModel();
    $result = $this->mod->delVideo($vid);
    if($result){
      echo '删除成功!<a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
        header("refresh:3;url='index.php?c=video&m=listvideos'");
    }
    else{
      echo "删除失败！<br/>";
        echo "<a href='index.php?c=video&m=listvideos'>返回</a>";
    }
  }


}

 ?>